/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : home.js                                 
*  Description  : 클럽개별메인 
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-06-14  이윤노    Created.  
*  2012-06-00  이윤노    Complete.  
*******************************************************************************/

jQuery(function($){
	
	function clsClubBoardView(){
		this._HTMLDom = null;
		this.clubBoardViewData = null;
		this.clubBoardViewNiceshot = null;
		this.clubInfo = null;
		this.niceList = null;
		
		this._init();	
	}
	
	clsClubBoardView.prototype = {
		_init: function(){
			$layer = $("div#container section#main_content div.golf_board article.board_view");
			this._HTMLDom = {
				"$layer": $layer
				,"$nice": $layer.find("div.help_box:eq(0)")
				, "$niceElement": $layer.find("div.help_box:eq(0) li:first")
				, "$imgLayer": $layer.find("div.picture")
				, "$imgElement": $layer.find("div.picture div.fr ul li:first")
			}
			$layer.find("div.picture>div>p").hide();
			//this.setViewEmpty();
		}
		, setData: function(thisData){
			this.clubBoardViewData = thisData;
			this.display();
		}
		, addProfile: function(oneData){
			this.clubBoardViewData["프로필"] = oneData;
		}
		, setClubInfo: function(thisData){
			this.clubInfo = thisData;	
		}
		, setNiceshotList: function(thisData){					
			this.clubBoardViewData["나이스샷"] = thisData;					
			this._HTMLDom["$layer"].find("th:eq(1) a:eq(0)").contents().filter(function(){
				return (this.nodeType==3&&this.data.trim());
			}).after(" 나이스샷("+ this.clubBoardViewData["나이스샷"].length + ")").remove();
		}
		, display: function(){
			var $title = this._HTMLDom["$layer"].find("dl.view_tit:eq(0)");
			var $content = this._HTMLDom["$layer"].find("table");
			var $nice = this._HTMLDom["$nice"];
			var $imgLayer = this._HTMLDom["$imgLayer"];
			var $imgElement = this._HTMLDom["$imgElement"];
			var thisClass = this;
			
			this.setViewControl();
			
			this.isRole();
			
			//제목, 프로필이미지, 닉네임
			$title.find("dt.tit_nice").contents().filter(function(){				
				return (this.nodeType==3&&this.data.trim())
			}).after(this.clubBoardViewData["제목"]["제목"]).remove();
			$title.find("dd span:eq(0) img").attr("src", _gf.filePath2Url(this.clubBoardViewData["제목"]["이미지"]));
			$title.find("dd span.nickname").html(this.clubBoardViewData["제목"]["닉네임"]).hover(function(event){
				_gf.showProfileLayer($(this), thisClass.clubBoardViewData["프로필"], "left", -12, $(this).height());
			}, function(event){
				_gf.objProfileLayer.hide();
			});							;
			
			//나이스샷			
			$content.find("thead th:eq(1) a:eq(0)").hover(function(event){					
				if(thisClass.clubBoardViewData["나이스샷"].length){
					_gf.showMemberLayer($(this), thisClass.clubBoardViewData["나이스샷"], "right", -100, $(this).height());
				}
			}, function(event){
				_gf.closeMemberLayer();
			});
			
			//공개여부,작성일,작성시간,조회수
			$content.find("thead th:eq(0) span:eq(0)").html((this.clubBoardViewData["공개유무"]=="A"?"전체공개":"동호회공개"));
			$content.find("thead tr th:eq(2) span:eq(1)").contents().filter(function(){
				return (this.nodeType==3&&this.data.trim())
			}).after(getFormatDateYmd(this.clubBoardViewData["내용"]["작성일"],"-")).remove();
			$content.find("thead tr th:eq(2) span:eq(1) span").html(getFormatTime(this.clubBoardViewData["내용"]["작성시간"],":"));
			$content.find("thead tr th:eq(3) span:eq(1)").html(getFormatNumber(this.clubBoardViewData["내용"]["조회수"]));
			
			//내용			
			$content.find("tbody tr td").contents().filter(function(){
				return (this.nodeType==3&&this.data.trim());
			}).after(this.clubBoardViewData["내용"]["내용"]).remove();
			
			//이미지
			$imgLayer.find("div.fr ul").empty();
			$imgLayer.find("p.fl img").attr("src", _gf.filePath2Url(this.clubBoardViewData["내용"]["업로드이미지"][0]["파일명"])).width(481);
			
			for(var i=0;i<this.clubBoardViewData["내용"]["업로드이미지"].length;++i){
				$imgLayer.find("div.fr ul").append($imgElement.clone(true));
			}
			
			$imgLayer.find("li").each(function(n){
				$(this).find("img").attr("src", _gf.filePath2Url(thisClass.clubBoardViewData["내용"]["업로드이미지"][n]["파일명"])).width(90).height(74);
				$(this).find("a").click(function(event){
					$imgLayer.find("p.fl img").attr("src", _gf.filePath2Url(thisClass.clubBoardViewData["내용"]["업로드이미지"][n]["파일명"])).width(481).height(315);
				});
			});
			
			$nice.hide();
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("dl:first, table:first").hide();
			if($layer.find("div#tmpSpin").length == 0){
				$layer.prepend("<div id='tmpSpin' style='position:relative; width:600px; height:100px;'></div>");
			}
			$layer.find("div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div#tmpSpin").hide().spin(false);
			$layer.find("dl, table").show();
		}
		, setViewControl: function(){
			if(this.clubBoardViewData["내글"]=="Y" || this.clubInfo["내상태"] =="1"){
				return;
			}
			//게시판글 수정 버튼 이벤트
			$("div#container section#main_content div.golf_board article.btn_area_box a img[alt=수정]").hide();
			//게시판글 삭제 버튼 이벤트
			$("div#container section#main_content div.golf_board article.btn_area_box a img[alt=삭제]").hide();
		}
		, getNiceLayer: function(){
			return this._HTMLDom["$layer"].find("th.btn_icon a:eq(0)");
		}
		, isRole: function(){			
			if(this.clubInfo["가입여부"] != '0'){
				if(this.clubBoardViewData["공개유무"] != "A"){
					alert("가입된 회원에게만 공개된 게시글입니다.");
					document.location.href = "club_picture_list.html?club_seq=" + this.clubInfo["동호회키"];
				}
			}
			
			if(this.clubBoardViewData["공개유무"] != "A"){
				this._HTMLDom["$layer"].find("thead th.btn_icon a:eq(1)").hide();
			}
		}
		, $getLayer: function(){
			return this._HTMLDom["$layer"];
		}
		, getInfo: function(){
			return this.clubBoardViewData;	
		}
	}
	
	function clsClubBoardViewReply(){
		this._HTMLDom = null;
		this.replyList = null;
		this.replyListNiceshot = null;
		this._init();
	}
	
	clsClubBoardViewReply.prototype = {
		_init: function(){
			$layer = $("div#container section#main_content div.golf_board article.board_view div.reply_area");
			this._HTMLDom = {
				"$layer": $layer
				, "$element": $layer.find("dl.first:first")
				, "$reply": $layer.find("div.help_box:first")
			}					
		}	
		, setList: function(thisData){
			this.replyList = thisData;
			this.display();
		}
		, addProfile: function(idx, oneData){
			this.replyList[idx]["프로필"] = oneData;
		}
		, setNiceshotList: function(idx, thisData){			
			this.replyList[idx]["나이스샷"] = thisData;						
			this._HTMLDom["$layer"].find("dd p.reply_nice a span").eq(idx).html("  나이스샷("+ getFormatNumber(this.replyList[idx]["나이스샷"].length) +")");
		}
		
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var $reply = this._HTMLDom["$reply"];
			var thisClass = this;
			
			$layer.find("dl").remove();
			$layer.find("div.help_box").remove();
			
			for(var i=0;i<this.replyList.length;++i){				
				$layer.find("div.reply_regist").before($element.clone(true)).before($reply.clone(true));	
			}
			
			//댓글수
			$layer.find("p.reply_num span").html("("+ this.replyList.length +")");
			//댓글입력칸
			$layer.find("div.reply_regist textarea").val("");
			//댓글목록
			$layer.find("dl").each(function(n){
				$(this).find("dt img").attr("src", _gf.filePath2Url(thisClass.replyList[n]["이미지"]));
				$(this).find("dd p.nickname a").html(thisClass.replyList[n]["닉네임"]).hover(function(event){
					_gf.showProfileLayer($(this), thisClass.replyList[n]["프로필"], "left", -12, $(this).height());
				}, function(event){
					_gf.objProfileLayer.hide();
				});
				$(this).find("dd p.reply_date").contents().filter(function(){
					return (this.nodeType==3&&this.data.trim())
				}).after(getFormatDateYmd(thisClass.replyList[n]["작성일"],"-")).remove();
				$(this).find("dd p.reply_date span:eq(0)").html(getFormatTime(thisClass.replyList[n]["작성시간"],":"));
				
			   //나이스샷				
				$(this).find("dd p.reply_nice a").hover(function(event){
					if(thisClass.replyList[n]["나이스샷"].length){
						_gf.showMemberLayer($(this), thisClass.replyList[n]["나이스샷"], "right", -100, $(this).height());
					}
				}, function(event){
					_gf.closeMemberLayer();
				}).find("span").html(" 나이스샷(0)");	
				
				//내용
				$(this).find("dd div").html(thisClass.replyList[n]["내용"]);
				if(thisClass.replyList[n]["본인글"] == "N") $(this).find("dd p.reply_del a img[alt=삭제]").hide();
			}).removeClass("first").eq(0).addClass("first");
			
			
		}
		, spinStart: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("dl").hide();
			if($layer.find("div#tmpSpin").length == 0){
				$layer.append("<div id='tmpSpin' style='position:relative; width:600px; height:100px;'></div>");
			}
			$layer.find("div#tmpSpin").show().spin();
		}
		, spinEnd: function(){
			var $layer = this._HTMLDom["$layer"];
			
			$layer.find("div#tmpSpin").hide().spin(false);
			$layer.find("dl").show();
		}
		, $getBtnDelete: function(){
			return this._HTMLDom["$layer"].find("dd p.reply_del a img[alt=삭제]");
		}
		, $getBtnInsert: function(){
			return this._HTMLDom["$layer"].find("div.reply_regist img[alt=댓글등록]");
		}
		, getReplyText: function(){					
			return this._HTMLDom["$layer"].find("div.reply_regist textarea").val();
		}
		, getNiceLayer: function(){
			return this._HTMLDom["$layer"].find("dd p.reply_nice a");
		}
	}
	
	function clsComm()
	{
		this.clubBoardView = null;
		this.clubBoardViewNiceshot=null;
		this.clubBoardViewRequest = null; 
		
		this.clubBoardViewReply = null;
		this.clubBoardViewReplyNiceshot = null;
		this.clubBoardViewReplyRequest = null;
			
		this._init();
	}
	
	clsComm.prototype = {
		_init: function(){	
		 	this.clubBoardViewRequest = {
		 		"동호회키" : null
		 		, "게시판키": null	
		 	}
		 	
		 	this.clubBoardViewReplyRequest = {
		 		"동호회키" : null
		 		, "게시판키": null	
		 		, "댓글키": null
		 	}
		}
//------------------------ 게시판상세------------------------//		
		, getClubBoardView: function(){			
			var thisClass = this;
			
			var szBoardSeq = this.clubBoardViewRequest["게시판키"];
				
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"getDetailClubBoard"
			}, {
				  "board_seq": szBoardSeq
				  , "modpage_yn": "N"
			}, function(ret){				
				if(ret["msp"]["contents"]["items"]){					
					
					var obj = ret["msp"]["contents"]["items"];
					var arr = [];
					
					if(obj["FileBean"] && obj["FileBean"][0] && obj["FileBean"][0]["items"]){
						if(!obj["FileBean"][0]["items"].length){
							obj["FileBean"][0]["items"] = new Array(obj["FileBean"][0]["items"]);
						}
						
						for(var i=0;i<obj["FileBean"][0]["items"].length;++i){
							arr.push({
								"파일키":_util.nvl(obj["FileBean"][0]["items"][i]["file__seq"])
								, "섬네일": _util.nvl(obj["FileBean"][0]["items"][i]["thumb"])
								, "파일명": _util.nvl(obj["FileBean"][0]["items"][i]["path"]) + _util.nvl(obj["FileBean"][0]["items"][i]["save__file__name"])
								, "원본파일명": _util.nvl(obj["FileBean"][0]["items"][i]["orgn__file__name"])
							});	
						}
					}
					
					//동호회목록
					thisClass.clubBoardView = {
						"제목": {
							"제목": _util.nvl(obj["title"])
							, "아이디": _util.nvl(obj["reg__id"])
							, "이미지": _util.nvl(obj["user__image"])
							, "닉네임" : _util.nvl(obj["reg__nickname"])
							, "나이스샷" : _util.nvl(obj["niceshot"])
						}
						, "내글": _util.nvl(obj["my__article__yn"])
						, "내용" : {
							"내용": _util.nvl(obj["content"])
							, "작성일": _util.nvl(obj["reg__date"])
							, "작성시간": _util.nvl(obj["reg__time"])
							, "조회수": _util.nvl(obj["hit"])
							, "업로드이미지": arr
						}
						, "나이스샷": []
						, "공개유무": _util.nvl(obj["view__type"])
						, "프로필": []
					};
				}
				
				$(thisClass).trigger("evtFinishClubBoardView");
			});
			
		}
		, getClubBoardViewData: function(){
			return this.clubBoardView;
		}
		, setClubBoardViewRequest: function(key, val){
			this.clubBoardViewRequest[key]=val;	
		}
//------------------------ 게시판상세------------------------//				
//------------------------ 게시판상세나이스샷------------------------//		
		, getClubBoardViewNiceshot: function(){
			var thisClass = this;
			
			var szBoardSeq = this.clubBoardViewRequest["게시판키"];
				
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"getClubBoardNiceshot"
			}, {
				  "board_seq": szBoardSeq
			}, function(ret){			
				
				thisClass.clubBoardViewNiceshot = [];
				
				if(ret["msp"]["contents"]["items"]){
					
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"] = new Array(ret["msp"]["contents"]["items"]);
					}
					
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						
						//나이스샷
						
						thisClass.clubBoardViewNiceshot.push({
							 "아이디": _util.nvl(obj["reg__id"])
							, "이미지": _util.nvl(obj["user__image"])
							, "닉네임":_util.nvl(obj["reg__nickname"])
						});
					}         
				}
				
				$(thisClass).trigger("evtFinishClubBoardViewNiceshot");
			});
		}
		, getClubBoardViewNiceshotData: function(){
			return this.clubBoardViewNiceshot;
		}
		
//------------------------ 게시판상세나이스샷------------------------//	
//------------------------ 게시판댓글------------------------//		
		, getClubBoardViewReply: function(){			
			var thisClass = this;
			var szBoardSeq = this.clubBoardViewReplyRequest["게시판키"];
				
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001"
				, "servicename":"getClubCommentList"
				, "listcount": 1000
				, "currpageno": 1
			}, {
				  "board_seq": szBoardSeq				  
			}, function(ret){
			
				// callback and mapping
				thisClass.clubBoardViewReply = [];
			
				if(ret["msp"]["contents"]["items"]){
					
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"] = new Array(ret["msp"]["contents"]["items"]);
					}
					
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						
						//동호회목록
						thisClass.clubBoardViewReply.push({
							"게시판키": _util.nvl(obj["board__seq"])
							,  "댓글키": _util.nvl(obj["reply__seq"])
							, "아이디": _util.nvl(obj["reg__id"])
							, "이미지": _util.nvl(obj["user__image"])
							, "닉네임": _util.nvl(obj["reg__nickname"])
							, "내용": _util.enter2br(_util.nvl(obj["content"]))
							, "본인글": _util.nvl(obj["my__article__yn"])
							, "작성일": _util.nvl(obj["reg__date"])
							, "작성시간": _util.nvl(obj["reg__time"])
							, "나이스샷수": _util.nvl(obj["niceshot"])
							, "나이스샷": []
							, "프로필": []
						});
					}         
				}
				
				$(thisClass).trigger("evtFinishClubBoardViewReply");				
			});
			
		}
		, getClubBoardViewReplyData: function(){			
			return this.clubBoardViewReply;
		}
		, setClubBoardViewReplyRequest: function(key, val){
			this.clubBoardViewReplyRequest[key]=val;
		}		
//------------------------ 게시판댓글------------------------//
//------------------------ 게시판댓글나이스샷------------------------//		
		, getClubBoardViewReplyNiceshot: function(arg){
			var thisClass = this;
			
			var szBoardSeq = this.clubBoardViewReplyRequest["게시판키"];
			var szReplySeq = arg["댓글키"];
			var idx = arg["인덱스"];
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"getClubBoardNiceshot"
			}, {
				  "board_seq": szBoardSeq
				  , "reply_seq": szReplySeq
			}, function(ret){			
				if(!thisClass.clubBoardViewReplyNiceshot) thisClass.clubBoardViewReplyNiceshot = [];
				thisClass.clubBoardViewReplyNiceshot[idx] = [];	
					
				if(ret["msp"]["contents"]["items"]){
				
					if(!ret["msp"]["contents"]["items"].length){
						ret["msp"]["contents"]["items"] = new Array(ret["msp"]["contents"]["items"]);
					}
					
					for(var i=0;i<ret["msp"]["contents"]["items"].length;i++){
						var obj = ret["msp"]["contents"]["items"][i];
						
						//나이스샷						
						thisClass.clubBoardViewReplyNiceshot[idx].push({
							 "아이디": _util.nvl(obj["reg__id"])
							, "이미지": _util.nvl(obj["user__image"])
							, "닉네임": _util.nvl(obj["reg__nickname"])
						});
					}
				}
				
				$(thisClass).trigger("evtFinishClubBoardViewReplyNiceshot", idx);
			});
		}
		, getClubBoardViewReplyNiceshotData: function(idx){
			return this.clubBoardViewReplyNiceshot[idx];
		}
		
//------------------------ 게시판댓글나이스샷------------------------//	
//------------------------ 등록/수정/삭제------------------------//		
		//게시글삭제
		, deleteBoard: function(arg){
			var thisClass = this;
			var szBoardSeq = arg["게시판키"];
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"deleteClubBoard"		
			}, {
				"board_seq": szBoardSeq		
			}, function(ret){
				var ret = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "CBR02"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishCUDBoard", [ret]);
			});
			// ajax 끝						
		}
		//댓글등록
		, InsertBoardViewReply: function(arg){
			var thisClass = this;
			var szBoardSeq = arg["게시판키"];
			var szReplyContens = arg["댓글"];
						
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"regClubComment"		
			}, {
				"board_seq": szBoardSeq				
				, "content": encodeURIComponent(szReplyContens)
			}, function(ret){
				
				var ret = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishCUDBaordViewReply",[ret]);
			});
			// ajax 끝
		}
		//댓글삭제
		, DeleteBoardViewReply: function(arg){
			var thisClass = this;
			var szClubSeq = arg["동호회키"];
			var szBoardSeq = arg["게시판키"];
			var szReplySeq = arg["댓글키"];
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"deleteClubComment"		
			}, {
				"board_seq": szBoardSeq				
				, "reply_seq": szReplySeq
			}, function(ret){
				
				var ret = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishCUDBaordViewReply",[ret]);
			});
			// ajax 끝
		}		
//------------------------ 등록/수정/삭제------------------------//		
//------------------------ 게시판글 나이스샷 등록------------------------//	
		, InsertBoardViewNiceshot: function(arg){
			var thisClass = this;
			var szBoardSeq = arg["게시판키"];
						
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"updateNiceshot"		
			}, {
				"board_seq": szBoardSeq			
			}, function(ret){
				var ret = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
				}
				
				$(thisClass).trigger("evtFinishInsertBaordViewNiceshot",[ret]);
			});
			// ajax 끝
		}
//------------------------ 게시판글 나이스샷 등록------------------------//	
//------------------------ 댓글 나이스샷 등록------------------------//			
		, InsertBoardViewReplyNiceshot: function(arg){
			var thisClass = this;
			var szBoardSeq = arg["게시판키"];
			var szReplySeq = arg["댓글키"];
			var idx = arg["인덱스"];
			
			// ajax 시작			
			//parameter setting and run
			_gf.ajax({
				"sid":"CB001",
				"servicename":"updateNiceshot"		
			}, {
				"board_seq": szBoardSeq			
				, "reply_seq": szReplySeq		
			}, function(ret){
				var ret = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"] == "00000"?true:false)
					, "메세지": _gf.getResultMsg(ret)
					, "게시판키": szBoardSeq
					, "댓글키": szReplySeq
					, "인덱스": idx
				}
				
				$(thisClass).trigger("evtFinishInsertBaordViewReplyNiceshot",[ret]);
			});
			// ajax 끝
		}
//------------------------ 댓글 나이스샷 등록------------------------//			
	}
	
	function clsControl()
	{
		this.club_seq = null;
		this.club_my = null;
		this.board_seq = null;
		
		this.objComm = null;
		
		this.objClubInfo = null
		this.objRole = null;
		
		this.objClubBoardView = null;
		this.objClubBoardViewReply = null;
		
		this._init();
		
		new clsSelfClubTop();
	}
	
	clsControl.prototype = {
		_init: function(){
			var member_id = _util.getCookie("member_id");
			
			this.club_seq = _util.getParam("club_seq");
			this.club_my = _util.getParam("club_my");
			this.board_seq = _util.getParam("board_seq");
					
			if(!member_id) {
				if(confirm("로그인 후 이용하여 주세요.")){
					_gf.goLogin();						
				}else{
					document.location.href = "../club/club.html";
				}
			}else if(!this.club_seq) {
				document.location.href = "../club/club.html";
			}
			
			this._preload();
			
			this.objComm = new clsComm();				
			this.objClubBoardView = new clsClubBoardView();
			this.objClubBoardViewReply = new clsClubBoardViewReply();
		
			this._beforeStart();
			this._bind();
		}
		, _preload: function(){
			_gf.spinStart();
		}
		, _beforeStart: function(){
			var thisClass = this;
			this._permitStart = {
				
			}
			
			$.ajax({
				url: "js/self_club_top.js"
				, dataType: "script"
				, async: false
				, success: function(){
					
				}
				, error: function(){
					alert("error");
				}
			});
			
			_util.executeThread(function(){
				for(var k in thisClass._permitStart){
					if(!thisClass._permitStart[k]) return false;
				}
				
				return (_clubControl.getClubInfo().infoData);
			}, function(){				
				_gf.spinEnd();;
				thisClass._start();
			});	
		}
		, _role: function(){
			if(!this.objRole.isMember()){//0-일반회원, 1-가입대기회원, 9-탈퇴회원
				//수정
				$("div#container section#main_content div.golf_board article.btn_area_box a img[alt=수정]").hide();
				//삭제
				$("div#container section#main_content div.golf_board article.btn_area_box a img[alt=삭제]").hide();
			}
		}
		, _start: function(){		
			this.objClubInfo = _clubControl.getClubInfo();
			this.objRole = new clsRole(this.objClubInfo.infoData);
			this._role();
			
			//게시판상세정보
			this.objClubBoardView.setClubInfo(this.objClubInfo.infoData);
			this.objComm.setClubBoardViewRequest("동호회키", this.club_seq);
			this.objComm.setClubBoardViewRequest("게시판키", this.board_seq);
			this.objClubBoardView.spinStart();
			this.objComm.getClubBoardView();
			
			//게시판댓글정보
			this.objComm.setClubBoardViewReplyRequest("동호회키", this.club_seq);
			this.objComm.setClubBoardViewReplyRequest("게시판키", this.board_seq);
			this.objClubBoardViewReply.spinStart();
			this.objComm.getClubBoardViewReply();				
		}
		, _bind: function(){
			var thisClass = this;
			
			// 게시판상세보기 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubBoardView", function(){
				var thisData = thisClass.objComm.getClubBoardViewData();
				thisClass.objClubBoardView.setData(thisData);				
				thisClass.objClubBoardView.spinEnd();
				thisClass.objComm.getClubBoardViewNiceshot();
;
				_gf.getMemberInfo({
					"아이디": thisData["제목"]["아이디"]					
					, "콜백": function(res, info, arg){
						thisClass.objClubBoardView.addProfile(info);
					}
				});
			});
	
			// 게시판상세보기댓글 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubBoardViewReply", function(){		
				var thisData = thisClass.objComm.getClubBoardViewReplyData();
				thisClass.objClubBoardViewReply.setList(thisData);				
				thisClass.objClubBoardViewReply.spinEnd();				
				
				for(var i=0;i<thisData.length;++i){					
					//나이스샷
					thisClass.objComm.getClubBoardViewReplyNiceshot({
						"댓글키":thisData[i]["댓글키"]
						, "인덱스": i
					});
					
					//프로필
					_gf.getMemberInfo({
						"아이디": thisData[i]["아이디"]					
						, "인덱스": i
						, "콜백": function(res, info, arg){
							thisClass.objClubBoardViewReply.addProfile(arg["인덱스"], info);
						}
					});
				}
				
			});
			
			// 게시판상세-나이스샷 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubBoardViewNiceshot", function(){			
				var thisData = thisClass.objComm.getClubBoardViewNiceshotData();				
				thisClass.objClubBoardView.setNiceshotList(thisData);				
			});
			
			// 댓글-나이스샷 조회 완료이벤트
			$(this.objComm).bind("evtFinishClubBoardViewReplyNiceshot", function(event, idx){
				var thisData = thisClass.objComm.getClubBoardViewReplyNiceshotData(idx);				
				thisClass.objClubBoardViewReply.setNiceshotList(idx,thisData);
			});
						
			// 게시판글 삭제 완료이벤트
			$(this.objComm).bind("evtFinishCUDBoard", function(event, resData){				
				alert(resData["메세지"]);				
				if(!resData["응답코드"]) return;		
				document.location.href = "home.html" + thisClass.returnParam();			
			});
			
			// 게시판상세보기댓글 등록/삭제 완료이벤트
			$(this.objComm).bind("evtFinishCUDBaordViewReply", function(event, resData){				
				alert(resData["메세지"]);				
				if(!resData["응답코드"]) return;				
				thisClass.objClubBoardViewReply.spinStart();
				thisClass.objComm.getClubBoardViewReply();			
			});
	
			// 게시판상세-나이스샷 등록 완료이벤트
			$(this.objComm).bind("evtFinishInsertBaordViewNiceshot", function(event, resData){				
				alert(resData["메세지"]);				
				if(!resData["응답코드"]) return;				
				thisClass.objComm.getClubBoardViewNiceshot();				
			});
			
			// 댓글-나이스샷 등록 완료이벤트
			$(this.objComm).bind("evtFinishInsertBaordViewReplyNiceshot", function(event, resData){				
				alert(resData["메세지"]);	
				if(!resData["응답코드"]) return;		
				//$(thisClass.objComm).trigger("evtFinishClubBoardViewReply");				
				
				thisClass.objComm.getClubBoardViewReplyNiceshot({
						"댓글키":resData["댓글키"]
						, "인덱스": resData["인덱스"]
				});
				
			});
			
			//글쓰기 버튼 이벤트
			$("div#container section#main_content div.golf_board article.depth2_tab p.btn_depth a").click(function(event){
				if(!thisClass.objRole.isMember()){
					alert(thisClass.objRole.getError());
					return;
				}
				document.location.href = "club_picture_write.html?club_seq=" + thisClass.club_seq;
			});
			
			//게시판글 목록 버튼 이벤
			$("div#container section#main_content div.golf_board article.btn_area_box span.left_btn a img[alt=목록]").click(function(event){
				document.location.href = "club_picture_list.html" + thisClass.returnParam();
			});
			
			//게시판글 수정 버튼 이벤트
			$("div#container section#main_content div.golf_board article.btn_area_box a img[alt=수정]").click(function(event){
				if(thisClass.objClubBoardView.clubBoardViewData["내글"]!="Y"){
					alert("본인글만 수정이 가능합니다.");	
					return;
				}
				document.location.href = "club_picture_write.html" + thisClass.returnParam();
			});
			
			//게시판글 삭제 버튼 이벤트
			$("div#container section#main_content div.golf_board article.btn_area_box a img[alt=삭제]").click(function(event){
				if(!confirm("게시물을 삭제 하시겠습니까?")) reutrn;
				
				var submitData = {
					"동호회키": thisClass.club_seq 
					, "게시판키" : thisClass.board_seq
				} 
				
				thisClass.objComm.deleteBoard(submitData);
			});			
			
			//댓글등록 버튼 이벤트
			this.objClubBoardViewReply.$getBtnInsert().click( function(event){
				var replyMsg = thisClass.objClubBoardViewReply.getReplyText();
				
				if(!thisClass.objRole.isMember()){
					alert(thisClass.objRole.getError());
					return;
				}
				
				if(!_gf.validComment(replyMsg)){
			     return;
			   }    
				
				var submitData = {
					"동호회키": thisClass.club_seq 
					, "게시판키" : thisClass.board_seq
					, "댓글": replyMsg					
				} 
				
				thisClass.objComm.InsertBoardViewReply(submitData);
			});
			
			//댓글삭제 버튼이벤트
			this.objClubBoardViewReply.$getBtnDelete().live("click", function(event){
				event.preventDefault();				
				
				var n = thisClass.objClubBoardViewReply.$getBtnDelete().index($(this));
				
				var submitData = {
					"동호회키": thisClass.club_seq 
					, "게시판키" : thisClass.board_seq
					, "댓글키": thisClass.objClubBoardViewReply.replyList[n]["댓글키"]
				} 
				
				thisClass.objComm.DeleteBoardViewReply(submitData);
			});
			
			//상세글정보 나이스샷 클릭 이벤트
			this.objClubBoardView.getNiceLayer().live("click",function(event){
				if(!thisClass.objRole.isMember()){
					alert(thisClass.objRole.getError());
					return;
				}
				
				var submitData = {
					"동호회키": thisClass.club_seq 
					, "게시판키" : thisClass.board_seq
				} 
				
				thisClass.objComm.InsertBoardViewNiceshot(submitData);
			});
			
			//댓글 나이스샷 클릭 이벤트
			this.objClubBoardViewReply.getNiceLayer().live("click",function(event){
				if(!thisClass.objRole.isMember()){
					alert(thisClass.objRole.getError());
					return;
				}
				
				var idx = thisClass.objClubBoardViewReply.getNiceLayer().index($(this));
				
				var submitData = {
					"동호회키": thisClass.club_seq 
					, "게시판키" : thisClass.board_seq
					, "댓글키": thisClass.objClubBoardViewReply.replyList[idx]["댓글키"]
					, "인덱스": idx
				} 				
				thisClass.objComm.InsertBoardViewReplyNiceshot(submitData);
			});
			
			//상세글정보 페이스북 클릭 이벤트
			//$(this.objClubBoardView).bind("FBFavor",function(event){
			$("div#container section#main_content").on("click", "a:contains('페이스북 공유하기')", function(){
				var info = thisClass.objClubBoardView.getInfo();
				
				var b = "";
				
				var $b = thisClass.objClubBoardView.$getLayer().find("div.picture li img").each(function(){
					b += "<img src='" + $(this).attr("src") + "' />";
				});
				
				var t = info["제목"]["제목"];
				var d = thisClass.objClubBoardView.$getLayer().find("div.view_detail").text();
				var r = document.location.href;				
				
				_util.facebook_sharer(t, d, b, r);
			});

		}
		// 댓글 완료
		, finishClubBoardViewReply: function(){
			$(this.objComm).trigger("evtFinishClubBoardViewReply");
		}
		, returnParam: function(){
			return "?club_seq="  + this.club_seq + "&board_seq=" + this.board_seq + "&club_my=" + this.club_my;
		}
	}
	
	document.objControl = new clsControl();
});